import httpCode from './http-code';
import locales from 'src/locales';

export interface IResponseData {
  code?: string | number;
  language?: string;
  data?: any;
}

export const responseData = (options: IResponseData) => {
  const code = options.code || 0;
  const language = options.language || 'zh-cn';
  return {
    code,
    message: locales(language)[httpCode[code.toString()]]
      ? locales(language)[httpCode[code.toString()]]
      : 'success',
    data: options.data,
  };
};
